﻿using EnvDTE80;
using System.Globalization;
using System.Reflection;
using System.Resources;

namespace dotNails {
	public abstract class CommandBase {
		protected static ResourceManager _rm = new ResourceManager("dotNails.dotNailsStrings", Assembly.GetExecutingAssembly());
		protected static CultureInfo _ci = System.Threading.Thread.CurrentThread.CurrentUICulture;

		private DTE2 _application;
		private EnvDTE.AddIn _addInInstance;
		private System.Guid _id = System.Guid.NewGuid();
		private string _caption;
		private string _tooltipText;
		protected System.Configuration.Configuration appConfig = System.Configuration.ConfigurationManager.OpenExeConfiguration(Assembly.GetExecutingAssembly().Location);

		public DTE2 Application {
			get { return _application; }
		}

		public EnvDTE.AddIn AddInInstance {
			get { return _addInInstance; }
		}

		public System.Guid ID {
			get {
				return _id;
			}
		}

		public string Name {
			get { return this.GetType().Name; }
		}

		public string Caption {
			get {
				return _caption;
			}
			set {
				_caption = value;
			}
		}

		public string TooltipText {
			get {
				return _tooltipText;
			}
			set {
				_tooltipText = value;
			}
		}

		public CommandBase(DTE2 application, EnvDTE.AddIn addInInstance, string captionCode, string tooltipTextCode) {
			_application = application;
			_addInInstance = addInInstance;
			_caption = _rm.GetString(captionCode);
			if (_caption == null || _caption == string.Empty) {
				_caption = captionCode;
			}
			_tooltipText = _rm.GetString(tooltipTextCode);
		}

		/// <summary>
		/// Performs this instance.
		/// </summary>
		public abstract void Perform();
	}
}
